package com.neuedu.lambda;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;

public class CommonLambda {

    public static void main(String[] args) {

        //方法引用
        Consumer<String> c =  System.out::println  ;
        c.accept("hello");

        List<Integer> list = new ArrayList();
        list.add(10);
        list.add(15);
        list.add(20);
        list.add(25);
        list.add(30);
        list.add(35);

//        for (Object o : list) {
//            System.out.println(o);
//        }
//        list.forEach( o ->    System.out.println(o));

//        list.forEach( System.out::println);

        list.forEach(( integer) ->   Student.say(integer)   );

        list.forEach(  Student::say  );




        //构造函数的引用
//        Supplier<Student> s1 =  () -> new Student();
        Supplier<Student> s1 =  Student::new;
        System.out.println( s1.get().getClass());

//        Supplier<String> s2 =  () -> new String();
        Supplier<String> s2 =   String::new;
        System.out.println(s2.get().getClass());






    }

}